<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('发射任务下发')"/>
</head>
<style>
	.layui-form-label {
		width: 150px !important;
		text-align: left !important;
	}

	.layui-form-item .layui-input-inline {
		width: 300px !important;
		margin-bottom: 0px !important;
	}

	.layui-form-item-te {
		margin-bottom: 0px !important;
	}
</style>
<form class="layui-form layui-form-pane" action="" id="playtaskform"  lay-filter="playtaskform">
	<div class="layui-form-item layui-form-item-te" style="padding-left: 10%;padding-top: 5%;">
		<label class="layui-form-label" style="width: 7%">台站ID</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="stationCode" name="stationCode" autocomplete="off" readonly>
		</div>
		<label class="layui-form-label" style="width: 7%">发射机ID</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="transCode" name="transCode" autocomplete="off" readonly>
		</div>
		<label class="layui-form-label" style="width: 7%">发射机通道号</label>
		<div class="layui-input-inline" style="width: 12%">
			<select id="taskId" name="taskId" lay-verify="required"  >
				<option value="0">通道0</option>
				<option value="1">通道1</option>
				<option value="2">通道2</option>
				<option value="3">通道3</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 10%;padding-top: 1%;">
		<label class="layui-form-label" style="width: 7%">任务开始时间</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="sendDateTime" name="sendDateTime" autocomplete="off" placeholder="yyyy-MM-dd HH:mm:ss" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">操作类型</label>
		<div class="layui-input-inline" style="width: 12%">
			<select id="operType" name="operType"  >
				<option value="1">新增</option>
				<option value="2">替换/修改</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">工作频率(3200~26100HZ)</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="channelFreq" name="channelFreq" autocomplete="off" lay-verify="required">
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 10%;padding-top: 1%;">
		<label class="layui-form-label" style="width: 7%">通道状态</label>
		<div class="layui-input-inline" style="width: 12%">
			<select id="channelRfChState" name="channelRfChState" >
				<option value="0">开</option>
				<option value="1">关</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">跳频时隙(0 ~ 50)</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="channelTimeSlot" name="channelTimeSlot" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">输出功率(0~+200)</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="channelEqualization" name="channelEqualization" autocomplete="off" lay-verify="required" >
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 10%;padding-top: 1%;">
		<label class="layui-form-label" style="width: 7%">调制模式</label>
		<div class="layui-input-inline" style="width: 12%">
			<select id="channelRfChMod" name="channelRfChMod" lay-verify="required"  >
				<option value="0">单音</option>
				<option value="1">AM</option>
				<option value="2">FM</option>
			</select>
		</div>
		<label class="layui-form-label" style="width: 7%">调制宽度(1000hz-4000hz)</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="channelRfChBand" name="channelRfChBand" autocomplete="off" lay-verify="required">
		</div>
		<label class="layui-form-label" style="width: 7%">音源</label>
		<div class="layui-input-inline" style="width: 12%">
			<select id="channelRfChASource" name="channelRfChASource" lay-verify="required" >
				<option value="0">白噪声</option>
				<option value="1">1k单音</option>
				<option value="2">外部音源</option>
				<option value="3">静音</option>
				<option value="4">文件白噪声</option>
				<option value="5">文件打击乐</option>
				<option value="6">播放URL音频</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 10%;padding-top: 1%;">
		<label class="layui-form-label" style="width: 7%">音源地址</label>
		<div class="layui-input-inline" style="width: 12%">
			<input type="text" class="layui-input" id="channelRfChAUrl" name="channelRfChAUrl" autocomplete="off"  lay-verify="required">
		</div>
	</div>v>
	<div class="layui-form-item layui-form-item-te" style="padding-left: 40%;padding-top: 2%;">
		<button class="pear-btn pear-btn-primary pear-btn-sm" lay-filter="dict-data-save" lay-submit=""
				type="submit">
			<i class="layui-icon layui-icon-ok"></i>
			提交
		</button>
		<button class="pear-btn pear-btn-sm" type="reset">
			<i class="layui-icon layui-icon-refresh"></i>
			重置
		</button>
	</div>
</form>
<th:block th:include="include :: footer"/>
<script>
	layui.use(['form', 'jquery','laydate'], function() {
		let form = layui.form;
		let $ = layui.jquery;
		let laydate = layui.laydate;
		let API_TRANSMITTER_PREFIX = "/api/transmitter/v1/";

		laydate.render({
			elem: '#sendDateTime',
			type: 'datetime',
			theme: 'grid'
		});

		$("#stationCode").val(GetQueryString("stationCode"));
		$("#transCode").val(GetQueryString("transCode"));

		var d = {};
		var t = $('#playtaskform').serializeArray();
		$.each(t, function() {
			d[this.name] = this.value;
		});
		form.on('submit(dict-data-save)', function(data) {
			$.ajax({
				url: API_TRANSMITTER_PREFIX + "playTask",
				data: JSON.stringify(data.field),
				dataType: 'json',
				contentType: 'application/json',
				type: 'post',
				success: function(result) {
					if (result.success) {
						layer.msg(result.msg, {
							icon: 1,
							time: 1000
						}, function() {
						});
					} else {
						layer.msg(result.msg, {
							icon: 2,
							time: 1000
						});
					}
				}
			})
			return false;
		});
		function GetQueryString(name) {
			const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			const r = window.location.search.substr(1).match(reg);
			if (r != null) return unescape(r[2]);
			return null;
		}
	})
</script>
</html>